package com.opennews.openplatform.service;

import com.opennews.openplatform.dto.CheckPermissionDto;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@RequiredArgsConstructor
@Service
public class AuthService {
    //    private final StringRedisTemplate redisTemplate;
    private final RedisTemplate<String, Object> redisTemplate;

    public void test() {
        CheckPermissionDto permission1 = new CheckPermissionDto();
        permission1.setResourceUri("http://url1");

        CheckPermissionDto permission2 = new CheckPermissionDto();
        permission2.setResourceUri("http://url2");

        List<CheckPermissionDto> permissions = new ArrayList();
        permissions.add(permission1);
        permissions.add(permission2);

        redisTemplate.opsForValue().set("permissions", permissions);
        List<CheckPermissionDto> list = (List<CheckPermissionDto>) redisTemplate.opsForValue().get("permissions");
        System.out.println(list.size());
    }
}
